﻿Imports DTO
Imports DAO
Imports GUI
Public Class ucThayDoiThamSo

    Private Sub ucThayDoiThamSo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim query As String
        query = "Select * from THAMSO"
        Dim DT As New DataTable()
        Dim DTP As New DataProvider()
        DT = DTP.Datatable_PHONGMACHTU(query)
        DTVThamSo.DataSource = DT
    End Sub

    Private Sub btnthaydoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthaydoi.Click
        Dim TS As New ThamSoDTO()
        Dim TS_BUS As New ThamSoBUS()
        Dim temp1 As Boolean, temp2 As Boolean
        temp1 = False
        temp2 = False
        If (cbxkhamtoida.Checked) Then
            temp1 = True
            Try
                TS.KhamToiDa = Long.Parse(txtkhamtoida.Text)
            Catch ex As Exception
                MessageBox.Show("Kham toi da : Du Lieu dien vao loi")
                Return
            End Try
            
        End If
        If (cbxtienkham.Checked) Then
            temp2 = True
            Try
                TS.TienKham = Long.Parse(txttienkham.Text)
            Catch ex As Exception
                MessageBox.Show("Tien Kham : Loi")
                Return
            End Try

        End If
        If (temp1 = False And temp2 = False) Then
            MessageBox.Show("check vao checkbox de chon thuoc tinh can sua")
            Return
        End If
        If (temp1 = True) Then
            Dim a As Integer
            a = TS_BUS.THAYDOIKHAMTOIDA(TS)
            If (a = 1) Then
                MessageBox.Show("Da Thay Doi so luong benh nhan toi da trong ngay")
            End If
        End If
        If (temp2 = True) Then
            Dim b As Integer
            b = TS_BUS.THAYDOITIENKHAM(TS)
            If (b = 1) Then
                MessageBox.Show("Da Thay Doi Tien Kham")
            End If
        End If
        ucThayDoiThamSo_Load(sender, e)
    End Sub
End Class
